<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.7
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

$menu = $params['menu'];


if(
    $this->checkPermission('perm_create_page')
    || $this->checkPermission('perm_edit_page')
    || $this->checkPermission('perm_manage_pages')
    || $this->checkPermission('perm_delete_pages')
    || $this->checkPermission('perm_import_page')
    || $this->checkPermission('perm_export_page')
    || $this->checkPermission('perm_import_block')
    || $this->checkPermission('perm_export_block')
    || $this->checkPermission('perm_import_template')

){


    


    /*
     * PAGES
     */

    $websiteContent = $menu->addItem(0, 'website-content', $this->lang('menu_title_website_content'));

    if($this->checkPermission('perm_create_page')
        || $this->checkPermission('perm_edit_page')
        || $this->checkPermission('perm_manage_pages')
        || $this->checkPermission('perm_delete_pages')
    ){

        // pages
        $p = $websiteContent->addItem(0, 'website-pages', $this->lang('menu_title_website_pages'), 'javascript: void(null)', '');

        if($this->checkPermission('perm_create_page')){
            // new page
            $url = $CONFIG->adminUrl.'/new-page/';
            $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
            $i = $p->addItem(0, 'new-page', $this->lang('menu_title_new_page'), $url, $icon);
            $i->set('class', 'redirect');
        }

        if($this->checkPermission('perm_edit_page') || $this->checkPermission('perm_delete_pages') || $this->checkPermission('perm_manage_pages')){
            // view pages
            $url = 'javascript: void(null)';
            $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
            $i = $p->addItem(0, 'view-pages', $this->lang('menu_title_view_pages'), $url, $icon);
            $i->set('id', 'jfx-pages');
        }

        if($this->checkPermission('perm_manage_pages')){
            // sort pages
            $url = $CONFIG->adminUrl.'/sort-pages/';
            $icon = $CONFIG->imageUrl.'/admin/icons/sort.gif';
            $i = $p->addItem(0, 'sort-pages', $this->lang('menu_title_sort_pages'), $url, $icon);
        }
    }



    /*
     * TEMPLATES
     */

    if($this->checkPermission('perm_create_templates')
        || $this->checkPermission('perm_edit_templates')
        || $this->checkPermission('perm_manage_templates')
        || $this->checkPermission('perm_delete_templates')
    ){

        // pages
        $t = $websiteContent->addItem(0, 'website-templates', $this->lang('menu_title_website_templates'), 'javascript: void(null)', '');

        if($this->checkPermission('perm_create_templates')){
            // new page
            $url = $CONFIG->adminUrl.'/templates/new/';
            $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
            $i = $t->addItem(0, 'new-template', $this->lang('menu_title_new_template'), $url, $icon);
        }

        if($this->checkPermission('perm_edit_templates') || $this->checkPermission('perm_delete_templates') || $this->checkPermission('perm_manage_templates')){
            // view pages
            $url = $CONFIG->adminUrl.'/templates/list/';
            $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
            $i = $t->addItem(0, 'view-templates', $this->lang('menu_title_view_templates'), $url, $icon);
        }

    }







    /*
     * IMPORT / EXPORT
     */




    if($this->checkPermission('perm_import_page') || $this->checkPermission('perm_export_page')
        || $this->checkPermission('perm_import_block') || $this->checkPermission('perm_export_block')
        || $this->checkPermission('perm_import_template')
    ){

        // import / export
        $importExport = $menu->addItem(1, 'import-export-section', $this->lang('menu_title_import_export'));
        $ie = $importExport->addItem(1, 'import-export', $this->lang('menu_title_import_export'), 'javascript: void(null)', '');


        if($this->checkPermission('perm_import_page')){
            // import page
            $url = $CONFIG->adminUrl.'/export/import-page/';
            $icon = $CONFIG->imageUrl.'/admin/icons/fold1.png';
            $i = $ie->addItem(0, 'import-page', $this->lang('menu_title_import_page'), $url, $icon);
        }

        if($this->checkPermission('perm_import_block')){
            // import block
            $url = $CONFIG->adminUrl.'/export/import-block/';
            $icon = $CONFIG->imageUrl.'/admin/icons/fold1.png';
            $i = $ie->addItem(1, 'import-block', $this->lang('menu_title_import_block'), $url, $icon);
        }

        if($this->checkPermission('perm_import_template')){
            // import template
            $url = $CONFIG->adminUrl.'/export/import-template/';
            $icon = $CONFIG->imageUrl.'/admin/icons/fold1.png';
            $i = $ie->addItem(2, 'import-template', $this->lang('menu_title_import_template'), $url, $icon);
        }

        if($this->checkPermission('perm_export_page')){
            // export page
            $url = $CONFIG->adminUrl.'/export/export-page/';
            $icon = $CONFIG->imageUrl.'/admin/icons/fold4.png';
            $i = $ie->addItem(3, 'export-page', $this->lang('menu_title_export_page'), $url, $icon);
        }

        if($this->checkPermission('perm_export_block')){
            // export block
            $url = $CONFIG->adminUrl.'/export/export-block/';
            $icon = $CONFIG->imageUrl.'/admin/icons/fold4.png';
            $i = $ie->addItem(4, 'export-block', $this->lang('menu_title_export_block'), $url, $icon);
        }
    }
}


    /*
     * USER MANAGEMENT
     */


if(
    $this->checkPermission('perm_users')
    || $this->checkPermission('perm_groups')
    || $this->checkPermission('perm_manage_users')
    || $this->checkPermission('perm_grant_permissions')
){
        // user management
        $userManagement = $menu->addItem(1, 'user-management', 'User Management');

        $staff = $userManagement->addItem(0, 'users-staff', $this->lang('menu_title_staff_management'), 'javascript: void(null)', '');

        if($this->checkPermission('perm_manage_users') || $this->checkPermission('perm_users')){
            // staff user list
            $url = $CONFIG->adminUrl.'/users/';
            $icon = $CONFIG->imageUrl.'/admin/icons/person1.png';
            $i = $staff->addItem(0, 'staff-list', $this->lang('menu_title_staff_users'), $url, $icon);
        }

        if($this->checkPermission('perm_grant_permissions')){
            // staff permissions
            $url = $CONFIG->adminUrl.'/perms/';
            $icon = $CONFIG->imageUrl.'/admin/icons/key-gold.png';
            $i = $staff->addItem(0, 'staff-permissions', $this->lang('menu_title_staff_permissions'), $url, $icon);
        }


    }



    /*
     * CONFIGURATION
     */



if($this->checkPermission('perm_manage_configuration')){


    $sysConfig = $menu->addItem(2, 'system-configuration', $this->lang('menu_title_system_configuration'));

    if($this->checkPermission('perm_install_modules') || $this->checkPermission('perm_uninstall_modules')){
        // modules and extensions
        $mods = $sysConfig->addItem(0, 'modules-extensions', $this->lang('menu_title_modules'));

        // module list
        $url = $CONFIG->adminUrl.'/modules/list/';
        $icon = $CONFIG->imageUrl.'/admin/icons/list1.png';
        $i = $mods->addItem(0, 'modules-list', $this->lang('menu_title_module_list'), $url, $icon);
    }


    if($this->checkPermission('perm_manage_languages') || $this->checkPermission('perm_translate_system')){
        // langs and translation
        $langs = $sysConfig->addItem(1, 'languages-translations', $this->lang('menu_title_languages'));

        if($this->checkPermission('perm_manage_languages')){
            // install lang
            $url = $CONFIG->adminUrl.'/lang/install/';
            $icon = $CONFIG->imageUrl.'/admin/icons/speech-download.png';
            $i = $langs->addItem(0, 'new-language', $this->lang('menu_title_install_language'), $url, $icon);
        }

        if($this->checkPermission('perm_translate_system')){
            // translate system
            $url = $CONFIG->adminUrl.'/lang/translate/';
            $icon = $CONFIG->imageUrl.'/admin/icons/speech-2-mixed.png';
            $i = $langs->addItem(1, 'translate-system', $this->lang('menu_title_translate_system'), $url, $icon);
        }
    
    }


    if($this->checkPermission('perm_manage_domains')){
        // domains and websites
        $doms = $sysConfig->addItem(2, 'domain-management', $this->lang('menu_title_domains'));

        // new domain
        $url = $CONFIG->adminUrl.'/domains/';
        $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
        $i = $doms->addItem(0, 'new-domain', $this->lang('menu_title_new_domain'), $url, $icon);

        // delete domain
        $url = $CONFIG->adminUrl.'/domains/';
        $icon = $CONFIG->imageUrl.'/admin/icons/delete.png';
        $i = $doms->addItem(1, 'delete-domain', $this->lang('menu_title_delete_domain'), $url, $icon);

        // set domain root
        $url = $CONFIG->adminUrl.'/domains/';
        $icon = $CONFIG->imageUrl.'/admin/icons/globe.png';
        $i = $doms->addItem(1, 'domain-root-page', $this->lang('menu_title_set_domain_root'), $url, $icon);
    }

    if(
        $this->checkPermission('perm_manage_workspaces')
        || $this->checkPermission('perm_publish_workspaces')
        || $this->checkPermission('perm_new_workspace')
    ){

        // workspaces and versioning
        $workspaces = $sysConfig->addItem(3, 'workspaces', $this->lang('menu_title_workspaces'));

        if($this->checkPermission('perm_manage_workspaces')){
            // list workspaces
            $url = $CONFIG->adminUrl.'/workspaces/list/';
            $icon = $CONFIG->imageUrl.'/admin/icons/workspaces.png';
            $i = $workspaces->addItem(0, 'workspace-list', $this->lang('menu_title_list_workspaces'), $url, $icon);
        }

        if($this->checkPermission('perm_new_workspace')){
            // new workspace
            $url = $CONFIG->adminUrl.'/workspaces/new/';
            $icon = $CONFIG->imageUrl.'/admin/icons/new.gif';
            $i = $workspaces->addItem(1, 'workspace-new', $this->lang('menu_title_new_workspace'), $url, $icon);
        }

        if($this->checkPermission('perm_manage_workspaces')){
            // workspace users
            $url = $CONFIG->adminUrl.'/workspaces/assign/';
            $icon = $CONFIG->imageUrl.'/admin/icons/person6.png';
            $i = $workspaces->addItem(2, 'workspace-assign', $this->lang('menu_title_workspace_users'), $url, $icon);
        }

        if($this->checkPermission('perm_publish_workspaces')){
            // workspace publishing
            $url = $CONFIG->adminUrl.'/workspaces/copy/';
            $icon = $CONFIG->imageUrl.'/admin/icons/file-copy.png';
            $i = $workspaces->addItem(3, 'workspace-copy', $this->lang('menu_title_merge_workspaces'), $url, $icon);
        }

    }
}




